package com.wxm.api;

import com.wxm.api.xml.Container;
import com.wxm.api.xml.CrawlerContainer;
import com.wxm.api.xml.CrawlerFiledContainer;
import org.dom4j.Element;


/**
 * <p>
 *      Container工厂
 * </p>
 *
 * @author wxm
 * @Date 2021/9/29
 */
public class ContainerFactory {
    private ContainerFactory(){}

    public static Container getContainer(Element element){
        String crawlingName = element.getName();
        Container crawling = null;
        if ("crawler".equals(crawlingName)){
            crawling = new CrawlerContainer();
        }else if ("crawler-filed".equals(crawlingName)){
            crawling = new CrawlerFiledContainer();
        }
        if (crawling == null) return null;
        return crawling.fillBaseAttribute(element);
    }
}
